package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.SickPerson;
import com.ruoyi.manage.service.ISickPersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 患者，一般对接第三方Controller
 * 
 * @author liuyangyang
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/manage/sickperson")
public class SickPersonController extends BaseController
{
    @Autowired
    private ISickPersonService sickPersonService;

    /**
     * 查询患者，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:list')")
    @GetMapping("/list")
    public TableDataInfo list(SickPerson sickPerson)
    {
        startPage();
        List<SickPerson> list = sickPersonService.selectSickPersonList(sickPerson);
        return getDataTable(list);
    }

    /**
     * 导出患者，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:export')")
    @Log(title = "患者，一般对接第三方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SickPerson sickPerson)
    {
        List<SickPerson> list = sickPersonService.selectSickPersonList(sickPerson);
        ExcelUtil<SickPerson> util = new ExcelUtil<SickPerson>(SickPerson.class);
        util.exportExcel(response, list, "患者，一般对接第三方数据");
    }

    /**
     * 获取患者，一般对接第三方详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:query')")
    @GetMapping(value = "/{sickPersonId}")
    public AjaxResult getInfo(@PathVariable("sickPersonId") Long sickPersonId)
    {
        return success(sickPersonService.selectSickPersonBySickPersonId(sickPersonId));
    }

    /**
     * 新增患者，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:add')")
    @Log(title = "患者，一般对接第三方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SickPerson sickPerson)
    {
        return toAjax(sickPersonService.insertSickPerson(sickPerson));
    }

    /**
     * 修改患者，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:edit')")
    @Log(title = "患者，一般对接第三方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SickPerson sickPerson)
    {
        return toAjax(sickPersonService.updateSickPerson(sickPerson));
    }

    /**
     * 删除患者，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:sickperson:remove')")
    @Log(title = "患者，一般对接第三方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sickPersonIds}")
    public AjaxResult remove(@PathVariable Long[] sickPersonIds)
    {
        return toAjax(sickPersonService.deleteSickPersonBySickPersonIds(sickPersonIds));
    }
}
